package stdio.costa.moca.model;

import javax.persistence.Entity;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang.StringUtils;

import stdio.costa.UuidPersistentable;
import stdio.costa.moca.pdf.PdfGeneratable;

@Entity
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Address extends UuidPersistentable implements PdfGeneratable {

	private static final long serialVersionUID = -6823986102615804451L;

	private String receiver;

	private String postcode;

	private String province;

	private String city;

	private String district;

	private String addressLine1;

	private String addressLine2;
	
	public Address() {
	}

	public Address(String receiver, String postcode, String province, String city, String district, String addressLine1, String addressLine2) {
		this.receiver = receiver;
		this.postcode = postcode;
		this.province = province;
		this.city = city;
		this.district = district;
		this.addressLine1 = addressLine1;
		this.addressLine2 = addressLine2;
	}

	@Override
	public boolean isReadyForPdfGeneration() {
		return StringUtils.isNotBlank(receiver) && StringUtils.isNotBlank(postcode)
				&& (StringUtils.isNotBlank(city) || StringUtils.isNotBlank(province))
				&& (StringUtils.isNotBlank(addressLine1) || StringUtils.isNotBlank(addressLine2));
	}

	public String getPostcode() {
		return postcode;
	}

	public void setPostcode(String postcode) {
		this.postcode = postcode;
	}

	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getDistrict() {
		return district;
	}

	public void setDistrict(String district) {
		this.district = district;
	}

	public String getAddressLine1() {
		return addressLine1;
	}

	public void setAddressLine1(String addressLine1) {
		this.addressLine1 = addressLine1;
	}

	public String getAddressLine2() {
		return addressLine2;
	}

	public void setAddressLine2(String addressLine2) {
		this.addressLine2 = addressLine2;
	}
}
